// 此处第二个参数vm，就是我们在页面使用的this，你可以通过vm获取vuex等操作，更多内容详见uView对拦截器的介绍部分：
// https://uviewui.com/js/http.html#%E4%BD%95%E8%B0%93%E8%AF%B7%E6%B1%82%E6%8B%A6%E6%88%AA%EF%BC%9F
const http = uni.$u.http
// 此处使用了传入的params参数，一切自定义即可
const getApiQ = (data = {}, config) => http.get('/frontend/login/wechat', {
	params: data,
	...config
});
const postApiQ = (params = {}, config) => http.post('/frontend/yard/redeemRecord', params, config);

/**
 * 测试登录
 */
const loginTest = (data = {}, config) => http.get('/frontend/login/test', {
	params: data,
	...config
});

/**
 * 商品分类
 */
const waresTypeMenu = (data = {}, config) => http.get('/frontend/mall/goods/type/goodsTypeList', {
	params: data,
	...config
});

/**
 * 商品详情
 */
const getGoodsDetail = (data = {}, config) => http.get('/frontend/mall/goods/getGoodsDetail', {
	params: data,
	...config
});


/**
 * 地址列表
 */
const addressListY = (data = {}, config) => http.get('/wechat/shipping/address/list', {
	params: data,
	...config
});


/**
 * 收货地址详情
 */
const getShippingAddressInfoY = (data = {}, config) => http.get('/wechat/shipping/address/getShippingAddressInfo', {
	params: data,
	...config
});
/**
 * 删除收货地址
 */
const delAddressY = (data = {}, config) => http.get('/wechat/shipping/address/delete', {
	params: data,
	...config
});
/**
 * 获取用户会员等级
 */
const getUserTypeY = (data = {}, config) => {
	return new Promise((resolve, reject) => {
	    resolve(data);
	});
};
/**
 * 立即支付(订单-待支付)
 */
const continuePaymentY = (data = {}, config) => http.get('/frontend/pay/continuePayment', {
	params: data,
	...config
});
/**
 * 获取购物车数量
 */
const getCartNumY = (data = {}, config) => http.get('/frontend/mall/goods/cart/getCartNum', {
	params: data,
	...config
});



// 上GET 下POST 上GET 下POST 上GET 下POST 上GET 下POST 上GET 下POST



/**
 * 登录接口
 */
const loginY = (params = {}, config) => http.post('/frontend/login/user', params, config);

/**
 * 商品列表
 */
const allProductsList = (params = {}) => http.post('/frontend/mall/goods/allProductsList', params);

/**
 * 添加-编辑收货地址
 */
const editAddressY = (params = {}) => http.post('/wechat/shipping/address/add', params);

/**
 * 立即购买-获取商品信息
 */
const payOrderInfoY = (params = {}) => http.post('/frontend/pay/confirmOrder', params);

/**
 * 选择优惠券
 */
const chooseCouponY = (params = {}) => http.post('/frontend/mall/coupon/chooseCoupon', params);

/**
 * 购物车列表
 */
const frontendGoodsCartY = (params = {}) => http.post('/frontend/mall/goods/cart/frontendGoodsCart', params);

/**
 * 新增删除购物车商品数量
 */
const updateCartNumY = (params = {}) => http.post('/frontend/mall/goods/cart/updateCartNum', params);

/**
 * 删除购物车中的商品
 */
const deleteCartY = (params = {}) => http.post('/frontend/mall/goods/cart/delete', params);

/**
 * 订单列表-用户
 */
const frontendOrderListY = (params = {}) => http.post('/frontend/mall/order/frontendOrderList', params);

/**
 * 退款列表-用户
 */
const refundOrderListY = (params = {}) => http.post('/frontend/mall/order/refund/frontendOrderList', params);

/**
 * 拉起支付
 */
const payToPayY = (params = {}) => http.post('/frontend/pay/toPay', params);

/**
 * 选择优惠券-多商品
 */
const chooseCouponsY = (params = {}) => http.post('/frontend/mall/coupon/chooseCoupons', params);


export default {
	getApiQ, //get示例接口
	postApiQ, //post示例接口
	loginY, //登录接口
	loginTest, //测试登录
	waresTypeMenu, //商品分类
	allProductsList, //商品列表
	getGoodsDetail, //商品详情
	addressListY, //地址列表
	editAddressY, //添加-编辑收货地址
	getShippingAddressInfoY, //收货地址详情
	delAddressY, //删除收货地址
	payOrderInfoY, //立即购买-获取商品信息
	chooseCouponY, //选择优惠券
	getUserTypeY, //获取用户会员等级
	frontendGoodsCartY, //购物车列表
	updateCartNumY, //新增删除购物车商品数量
	deleteCartY, //删除购物车中的商品
	frontendOrderListY, //订单列表-用户
	refundOrderListY, //退款列表-用户
	payToPayY, //拉起支付
	chooseCouponsY,//选择优惠券-多商品
	continuePaymentY,//立即支付(订单-待支付)
	getCartNumY,//获取购物车数量
}